package com.tengju.data.infrastructure.repository.convert;

import com.tengju.data.domain.model.wx.WxRequestRecord;
import com.tengju.data.domain.model.wx.WxRequestRecordStatus;
import com.tengju.data.domain.model.wx.WxRequestRecordType;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.WxRequestRecordDO;

/**
 * @author: 李大仙
 * @date: 2021/11/5 11:12 上午
 */
public class WxRequestRecordConvert {
    public static WxRequestRecord convert(WxRequestRecordDO wxRequestRecordDO) {
        if (wxRequestRecordDO == null) {
            return null;
        }
        return new WxRequestRecord(
                wxRequestRecordDO.getId(),
                WxRequestRecordType.form(wxRequestRecordDO.getType()),
                wxRequestRecordDO.getBefore(),
                wxRequestRecordDO.getAfter(),
                WxRequestRecordStatus.form(wxRequestRecordDO.getStatus())
        );
    }

    public static WxRequestRecordDO convert(WxRequestRecord wxRequestRecord) {
        if (wxRequestRecord == null) {
            return null;
        }
        WxRequestRecordDO wxRequestRecordDO = new WxRequestRecordDO();
        wxRequestRecordDO.setId(wxRequestRecord.getId());
        wxRequestRecordDO.setType(wxRequestRecord.getType().getCode());
        wxRequestRecordDO.setBefore(wxRequestRecord.getBefore());
        wxRequestRecordDO.setAfter(wxRequestRecord.getAfter());
        wxRequestRecordDO.setStatus(wxRequestRecord.getStatus().getCode());
        return wxRequestRecordDO;
    }
}
